package com.hys.param;

import com.hys.common.PageParam;
import com.hys.entity.CoopInfo;
import com.hys.entity.User;
import com.hys.enums.CoopStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.Valid;

@Data
@ApiModel
public class CooperAddOrUpdateParam {

    @ApiModelProperty("info表ID")
    private Integer id;

    @ApiModelProperty("企业信息")
    @Valid
    private EnterpriseParam enterpriseParam;

    @ApiModelProperty("合作信息")
    @Valid
    private CooperInfoParam cooperInfoParam;

    @ApiModelProperty("合作方式")
    private CooperMethodParam cooperMethodParam;

    @ApiModelProperty("合作内容")
    private CooperContentParam cooperContentParam;

    /**
     * 转换获取coopInfo
     * @return
     */
    public CoopInfo getCoopInfo(User user) {
        CoopInfo coopInfo = new CoopInfo();
        coopInfo.setEnterpriseName(enterpriseParam.getName());
        coopInfo.setMajor(cooperInfoParam.getMajor());
        coopInfo.setSchoolContactPerson(cooperInfoParam.getSchoolContactPerson());
        coopInfo.setEnterpriseContactPerson(cooperInfoParam.getEnterpriseContactPerson());
        coopInfo.setEnterpriseContactPhone(cooperInfoParam.getEnterpriseContactPhone());
        coopInfo.setIsAgreeSigned(cooperInfoParam.getIsAgreeSigned());
        coopInfo.setIsDonation(cooperMethodParam.getIsDonation());
        coopInfo.setIsAcceptGraduate(cooperMethodParam.getIsAcceptGraduate());
        coopInfo.setIsCoBuildBook(cooperContentParam.getIsCoBuildBook());
        coopInfo.setIsApprentice(cooperContentParam.getIsApprentice());
        coopInfo.setIsCoopEffect(cooperContentParam.getIsCoopEffect());
        coopInfo.setStatus(CoopStatusEnum.BUILD.getCode());
        coopInfo.setDeptNo(user.getDeptNo());
        coopInfo.setUpdateUser(user.getId());
        return coopInfo;
    }


    /**
     * 当是否为否的时候处理
     * @return
     */
    public void delWhenBooleanIsFalse(){
        cooperMethodParam.delWhenBooleanIsFalse();
        cooperContentParam.delWhenBooleanIsFalse();
    }

}
